﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        /*---------公共元素---------------------------------------*/* { padding: 0; margin: 0; font-size: 12px; font-family: Arial,宋体,Tahoma; }
        body { padding: 12px; background-color: #fff; }
        table, tr, td { border-collapse: collapse; }
        input, img { vertical-align: middle; }
        input { padding: 2px; }
        img { border: 0; }
        ul, li { list-style-type: none; }
        /*--------------------------------------------------------*//* 链接颜色 */a:link { color: #328916; text-decoration: none; }
        a:visited { color: #328916; text-decoration: none; }
        a:hover { color: #328916; text-decoration: underline; }
        a:active { color: #328916; }
        /*------------------公共类---------------------------------*//*.content { margin: 0 auto; width: 980px; }*/.ptitle { padding: 5px; height: 17px; border: solid 1px #97C193; background: url(/crm/images/bgt.jpg) repeat-x; margin-top: 20px; font-weight: bold; font-size: 14px; }
        .inputtxt { padding: 4px; border: solid 1px #C3C3C3; border-top: solid 1px #7C7C7C; background-color: #fff; }
        .tblist tr td { padding: 5px; border: solid 1px #97C193; }
        .tblist tr td div td { padding: 0px; border: 0; }
        /*表格样式2*/.tb2 tr td { padding: 5px; border: solid 1px #C5E7C6; }
        .tb2 .nav { height: 28px; background: #ffffff url(/images/my/bg_grid_m.png) repeat-x; }
        .tb2 .nav td { font-weight: bold; font-size: 14px; color: #333; padding: 10px 20px; }
        .tb2 .bg { background-color: #F6FBF2; }
    </style>

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

    <script src="../filewatch/lhgdialog/lhgdialog.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        function getparas(item)
        {
            var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)", "i"));
            return svalue ? svalue[1] : svalue;
        }
        $(document).ready(function()
        {
            //加载配置
            $.post("/ashx/postop.ashx?ac=getdatapluginconfig", { type: getparas("type"), id: getparas("id"), fn: getparas("fn") }, function(res)
            {
                try
                {
                    var jsondata = eval("[" + res + "]");
                    $("#txtWidth").val(jsondata[0].pic_width);
                    $("#txtHeight").val(jsondata[0].pic_height);
                    $("#txtdelaytime").val((jsondata[0].stop_time) / 1000);
                    $("#chkisshowtext").attr("checked", jsondata[0].show_text == "1" ? true : false);
                    var da = eval(decodeURI(jsondata[0].data));
                    for (var j = 0; j < da.length; j++)
                    {
                        var le = $("#tb1 tbody tr").length;
                        if (j >= le)
                        {
                            $("#btnadd").click();
                        }
                        var thetr = $("#tb1 tbody tr")[j];

                        $(thetr).find(".small").val(da[j].image);
                        $(thetr).find(".tip").val(da[j].text);
                        $(thetr).find(".link").val(da[j].link);

                    }
                } catch (ex) { throw ex; }
            });

            //var DG = frameElement.lhgDG;
            jQuery.selfile = function(obj)
            {

                var fromid = "img" + $(obj).parents('tr').index();
                var dg = new $.dialog({ title: '选择文件', id: 'selfile' + fromid, page: '/plugins/filewatch/filelist.aspx?root=~/upload&fromid=' + fromid + '&' + Math.random(), autoSize: false, width: 800, height: 500, cover: true, bgcolor: '#000', opacity: 0.3 });
                dg.ShowDialog();
            }
            $("#btnadd").click(function()
            {
                var index = $("#tb1 tr:last").index() + 1;
                $("#tb1 tr:last").after("<tr><td><input class=link type=\"text\"  style='width:120px;'/></td><td><input class=\"tip\" type=\"text\" style=\"width: 100px;\"></td><td><input type=\"text\" id=\"img" + index + "\" class=small style='width:200px;'/> <input type=\"button\" onclick=\"$.selfile(this);\" class=\"brower\" value=\"选择文件\" /></td><td><a style='cursor:pointer;' onclick=\"javascript:$(this).parents('tr').remove();\">删除</a></td></tr>");
            });

            $("#btncreate").click(function()
            {
                if (!getparas("id"))
                {
                    alert("参数传递不完整!");
                    return false;
                }
                var str = " <scr" + "ipt type=\"text/javascript\" src=\"/plugins/flashwheel/flash.js\"></scr" + "ipt>\n";
                str += "<scr" + "ipt type=\"text/javascr" + "ipt\">\n";
                str += " var pic_width = " + $.trim($("#txtWidth").val()) + "; //图片宽度\n";
                str += " var pic_height =  " + $.trim($("#txtHeight").val()) + "; //图片高度\n";
                str += " var button_pos = 4; //按扭位置 1左 2右 3上 4下\n";
                str += " var stop_time = " + $.trim($("#txtdelaytime").val()) * 1000 + "; //图片停留时间(1000为1秒钟)\n";
                var isshow = "0";
                if ($("#chkisshowtext").is(':checked'))
                {
                    str += " var show_text = 1; //是否显示文字标签 1显示 0不显示\n";
                    isshow = "1";
                }
                else
                {
                    str += " var show_text = 0; //是否显示文字标签 1显示 0不显示\n";
                }
                str += " var txtcolor = \"000000\"; //文字色\n";
                str += " var bgcolor = \"DDDDDD\"; //背景色\n";
                str += " var data=[";
                //                var data = "[{\"link\":\"http://www.baidu.com\",\"image\":\"/upload/背景/Chrysanthemum.jpg\",\"text\":\"说明文字\"},{\"link\":\"http://www.baidu.com\",\"image\":\"/upload/背景/Desert.jpg\",\"text\":\"说明文字\"},{\"link\":\"http://www.baidu.com\",\"image\":\"/upload/背景/Hydrangeas.jpg\",\"text\":\"说明文字\"}]";
                var data = "";
                $("#tb1 tbody tr").each(function()
                {
                    var src = $.trim($(this).find(".small").val());
                    var text = $.trim($(this).find(".tip").val());
                    var link = $.trim($(this).find(".link").val());
                    if (src != "")
                    {
                        data += "{\"link\":\"" + link + "\",\"image\":\"" + src + "\",\"text\":\"" + text + "\"},";
                    }
                });
                if (data.length > 0)
                    data = data.substr(0, data.length - 1);
                str += data + "]\n";
                str += " showflash();\n</scri" + "pt>";
                data = encodeURI(data);
                var paras = "{\"pic_width\":\"" + $.trim($("#txtWidth").val()) + "\",\"pic_height\":\"" + $.trim($("#txtHeight").val()) + "\",\"stop_time\":\"" + $.trim($("#txtdelaytime").val()) * 1000 + "\",\"show_text\":" + isshow + ",\"data\":\"[" + data + "]\"}";
                $.post("/ashx/postop.ashx?ac=pluginconfig", { type: getparas("type"), id: getparas("id"), fn: getparas("fn"), datastr: str, paras: paras }, function(res)
                {
                    var DG = frameElement.lhgDG;
                    if (DG != null)
                    {                       
                        top.ReLoad();
                        DG.cancel();
                    }
                });
            });

        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div style="width: 600px;">
        生成图片轮换代码
        <table id="tb1" class="tb2">
            <thead>
                <tr>
                    <td colspan="4" align="left" style="text-align: left;">
                        宽度：<input id="txtWidth" style="width: 100px;" value="300" maxlength="4" type="text" />&nbsp;&nbsp;
                        高度：<input id="txtHeight" type="text" value="200" maxlength="4" style="width: 100px;" />
                        显示文字：<input id="chkisshowtext" type="checkbox" checked="checked" />
                        提留时间：<input id="txtdelaytime" type="text" maxlength="4" value="6" style="width: 100px;" />秒
                    </td>
                </tr>
                <tr style="background-color: #e5e5e5;">
                    <td>
                        图片链接
                    </td>
                    <td>
                        文本
                    </td>
                    <td>
                        图片
                    </td>
                    <td>
                        操作
                    </td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        <input class="link" type="text" style="width: 120px;">
                    </td>
                    <td>
                        <input class="tip" type="text" style="width: 100px;">
                    </td>
                    <td>
                        <input type="text" id="img0" class="small" style="width: 200px;">
                        <input type="button" onclick="$.selfile(this);" class="brower" value="选择文件">
                    </td>
                    <td>
                        <a style="cursor: pointer;" onclick="javascript:$(this).parents('tr').remove();">删除</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input class="link" type="text" style="width: 120px;">
                    </td>
                    <td>
                        <input class="tip" type="text" style="width: 100px;">
                    </td>
                    <td>
                        <input type="text" id="img1" class="small" style="width: 200px;">
                        <input type="button" onclick="$.selfile(this);" class="brower" value="选择文件">
                    </td>
                    <td>
                        <a style="cursor: pointer;" onclick="javascript:$(this).parents('tr').remove();">删除</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input class="link" type="text" style="width: 120px;">
                    </td>
                    <td>
                        <input class="tip" type="text" style="width: 100px;">
                    </td>
                    <td>
                        <input type="text" id="img2" class="small" style="width: 200px;">
                        <input type="button" onclick="$.selfile(this);" class="brower" value="选择文件">
                    </td>
                    <td>
                        <a style="cursor: pointer;" onclick="javascript:$(this).parents('tr').remove();">删除</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input class="link" type="text" style="width: 120px;">
                    </td>
                    <td>
                        <input class="tip" type="text" style="width: 100px;">
                    </td>
                    <td>
                        <input type="text" id="img3" class="small" style="width: 200px;">
                        <input type="button" onclick="$.selfile(this);" class="brower" value="选择文件">
                    </td>
                    <td>
                        <a style="cursor: pointer;" onclick="javascript:$(this).parents('tr').remove();">删除</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input class="link" type="text" style="width: 120px;">
                    </td>
                    <td>
                        <input class="tip" type="text" style="width: 100px;">
                    </td>
                    <td>
                        <input type="text" id="img4" class="small" style="width: 200px;">
                        <input type="button" onclick="$.selfile(this);" class="brower" value="选择文件">
                    </td>
                    <td>
                        <a style="cursor: pointer;" onclick="javascript:$(this).parents('tr').remove();">删除</a>
                    </td>
                </tr>
            </tbody>
        </table>
        <input type="button" id="btnadd" value="新增一行" />
        <input type="button" id="btncreate" value="提交" />
    </div>
    </form>
</body>
</html>
